import { fileURLToPath, URL } from 'node:url'
import dotenv from 'dotenv';
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'


dotenv.config({ path: `.env.${process.env.NODE_ENV}` });
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx()],
  server: {
    proxy: {
      '^/api': {
        target: 'http://127.0.0.1:9988/api',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '^/configapi': {
        target: 'http://127.0.0.1:9988',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/configapi/, ''),
      },
    }
  },
  base: process.env.VITE_BASE_PATH, //设置项目的根目录
  build: {
    outDir: 'goGinWeb' // 打包文件的输出目录
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
